require 'digest/sha1' # builtin

module RongCloud
  
  module Signature
    
    def signature(nonce, timestamp)
      # append
      str = "#{RongCloud::Config.app_secret}#{nonce}#{timestamp}"
      Digest::SHA1.hexdigest(str)
    end
  
    
    def signed_headers
      nonce = rand(10 * 6)
      timestamp = Time.now.to_i
      signature = signature(nonce, timestamp)
      #return
      {
        'App-Key' => RongCloud::Config.app_key,
        'Nonce' => nonce,
        'Timestamp' => timestamp,
        'Signature' => signature
      }
    end

  end # end Signature
end
